package com.leyou.sms.config;

import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.sms.v20190711.SmsClient;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@SuppressWarnings("ALL")
/**
 * @Description :
 * @author     :LD
 */
@Configuration
@EnableConfigurationProperties(SmsProperties.class)
public class SmsConfiguration {
    @Bean
    public SmsClient smsClient(SmsProperties smsProperties){
        //实例化一个认证对象,需要腾讯云密钥
        Credential cred = new Credential(smsProperties.getSecretId(), smsProperties.getSecretKey());
        //配置信息
        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setConnTimeout(smsProperties.getConnTimeout());
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setHttpProfile(httpProfile);
        return new SmsClient(cred, "",clientProfile);
    }
}
